<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>emaclite: xemaclite_example_util.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">emaclite
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="pages.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xemaclite__example__util_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xemaclite_example_util.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file implements the utility functions for the EmacLite example code. </p>
<pre>
 MODIFICATION HISTORY:</pre><pre> Ver   Who  Date     Changes
</p>
<hr/>
<p>
 2.00a  ktn 04/13/09 First release
 2.00a  ktn 06/13/09 Changed the EmacLitePhyDetect function so that
                      the function is not in an infinite loop in case of a
                      faulty Phy device.
 3.03a  bss 09/01/12 Moved the declarations of RecvFrameLength,
                     TransmitComplete, EmacLiteInstance
                      TxFrame[XEL_MAX_FRAME_SIZE], RxFrame[XEL_MAX_FRAME_SIZE]
                      from the <a class="el" href="xemaclite__example_8h.html" title="Defines common data types, prototypes, and includes the proper headers for use with the EmacLite exam...">xemaclite_example.h</a>
                      to this file for fixing C++ compilation errors
 4.9    ml  11/15/23 Fix compilation errors reported with -std=c2x compiler flag
</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a2799884dbcd4e24e3f7fda067d457567"><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xemaclite__example__util_8c.html#a2799884dbcd4e24e3f7fda067d457567">EmacLitePhyDetect</a> (<a class="el" href="struct_x_emac_lite.html">XEmacLite</a> *InstancePtr)</td></tr>
<tr class="memdesc:a2799884dbcd4e24e3f7fda067d457567"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function detects the PHY address by looking for successful MII status register contents (PHY register 1).  <a href="#a2799884dbcd4e24e3f7fda067d457567">More...</a><br/></td></tr>
<tr class="separator:a2799884dbcd4e24e3f7fda067d457567"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae929ecf7843aa6c7ca8a09b5cf6746c7"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xemaclite__example__util_8c.html#ae929ecf7843aa6c7ca8a09b5cf6746c7">EmacLiteEnablePhyLoopBack</a> (<a class="el" href="struct_x_emac_lite.html">XEmacLite</a> *InstancePtr, u32 PhyAddress)</td></tr>
<tr class="memdesc:ae929ecf7843aa6c7ca8a09b5cf6746c7"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function enables the MAC loopback on the PHY.  <a href="#ae929ecf7843aa6c7ca8a09b5cf6746c7">More...</a><br/></td></tr>
<tr class="separator:ae929ecf7843aa6c7ca8a09b5cf6746c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1f1980c002b40ba720934300f6960124"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xemaclite__example__util_8c.html#a1f1980c002b40ba720934300f6960124">EmacLiteDisablePhyLoopBack</a> (<a class="el" href="struct_x_emac_lite.html">XEmacLite</a> *InstancePtr, u32 PhyAddress)</td></tr>
<tr class="memdesc:a1f1980c002b40ba720934300f6960124"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function disables the MAC loopback on the PHY.  <a href="#a1f1980c002b40ba720934300f6960124">More...</a><br/></td></tr>
<tr class="separator:a1f1980c002b40ba720934300f6960124"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae9b61e9b176db206875b77fb002fff05"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xemaclite__example__util_8c.html#ae9b61e9b176db206875b77fb002fff05">EmacLitePhyDelay</a> (unsigned int Seconds)</td></tr>
<tr class="memdesc:ae9b61e9b176db206875b77fb002fff05"><td class="mdescLeft">&#160;</td><td class="mdescRight">For PPC we use a usleep call, for Microblaze we use an assembly loop that is roughly the same regardless of optimization level, although caches and memory access time can make the delay vary.  <a href="#ae9b61e9b176db206875b77fb002fff05">More...</a><br/></td></tr>
<tr class="separator:ae9b61e9b176db206875b77fb002fff05"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a1f1980c002b40ba720934300f6960124"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int EmacLiteDisablePhyLoopBack </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_emac_lite.html">XEmacLite</a> *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>PhyAddress</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function disables the MAC loopback on the PHY. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>is the pointer to the instance of EmacLite driver. </td></tr>
    <tr><td class="paramname">PhyAddress</td><td>is the address of the Phy device.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS if the loop back was disabled.</li>
<li>XST_FAILURE if the loop back was not disabled.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="group__emaclite.html#ga444ab091bdc373bf2e1a266d5febecd0">XEmacLite_PhyRead()</a>, and <a class="el" href="group__emaclite.html#ga63ef92abf534fcf6f41601e93efa4cc7">XEmacLite_PhyWrite()</a>.</p>

<p>Referenced by <a class="el" href="xemaclite__intr__example_8c.html#a96917622015e54b4adfc30cf3bc43b65">EmacLiteIntrExample()</a>, <a class="el" href="xemaclite__phy__loopback__example_8c.html#ab4299bd01a872463e209d193501a22d2">EmacLitePhyLoopbackExample()</a>, and <a class="el" href="xemaclite__polled__example_8c.html#a47117ea81b169056edf42281fab91cc2">EmacLitePolledExample()</a>.</p>

</div>
</div>
<a class="anchor" id="ae929ecf7843aa6c7ca8a09b5cf6746c7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int EmacLiteEnablePhyLoopBack </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_emac_lite.html">XEmacLite</a> *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>PhyAddress</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function enables the MAC loopback on the PHY. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>is the pointer to the instance of EmacLite driver. </td></tr>
    <tr><td class="paramname">PhyAddress</td><td>is the address of the Phy device.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS if the loop back is enabled.</li>
<li>XST_FAILURE if the loop back was not enabled.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="xemaclite__example_8h.html#ae9b61e9b176db206875b77fb002fff05">EmacLitePhyDelay()</a>, and <a class="el" href="group__emaclite.html#ga63ef92abf534fcf6f41601e93efa4cc7">XEmacLite_PhyWrite()</a>.</p>

<p>Referenced by <a class="el" href="xemaclite__intr__example_8c.html#a96917622015e54b4adfc30cf3bc43b65">EmacLiteIntrExample()</a>, <a class="el" href="xemaclite__phy__loopback__example_8c.html#ab4299bd01a872463e209d193501a22d2">EmacLitePhyLoopbackExample()</a>, and <a class="el" href="xemaclite__polled__example_8c.html#a47117ea81b169056edf42281fab91cc2">EmacLitePolledExample()</a>.</p>

</div>
</div>
<a class="anchor" id="ae9b61e9b176db206875b77fb002fff05"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EmacLitePhyDelay </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>Seconds</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>For PPC we use a usleep call, for Microblaze we use an assembly loop that is roughly the same regardless of optimization level, although caches and memory access time can make the delay vary. </p>
<p>Just keep in mind that after resetting or updating the PHY modes, the PHY typically needs time to recover.</p>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None </dd></dl>

<p>Referenced by <a class="el" href="xemaclite__example__util_8c.html#ae929ecf7843aa6c7ca8a09b5cf6746c7">EmacLiteEnablePhyLoopBack()</a>.</p>

</div>
</div>
<a class="anchor" id="a2799884dbcd4e24e3f7fda067d457567"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u32 EmacLitePhyDetect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_emac_lite.html">XEmacLite</a> *&#160;</td>
          <td class="paramname"><em>InstancePtr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function detects the PHY address by looking for successful MII status register contents (PHY register 1). </p>
<p>It looks for a PHY that supports auto-negotiation and 10Mbps full-duplex and half-duplex. So, this code won't work for PHYs that don't support those features, but it's a bit more general purpose than matching a specific PHY manufacturer ID.</p>
<p>Note also that on some (older) Xilinx ML4xx boards, PHY address 0 does not properly respond to this query. But, since the default is 0 and assuming no other address responds, then it seems to work OK.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">InstancePtr</td><td>is the pointer to the instance of EmacLite driver.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The address of the PHY device detected (returns 0 if not detected).</dd></dl>
<dl class="section note"><dt>Note</dt><dd>The bit mask (0x1808) of the MII status register (PHY Register 1) used in this function are: 0x1000: 10Mbps full duplex support. 0x0800: 10Mbps half duplex support. 0x0008: Auto-negotiation support. </dd></dl>

<p>References <a class="el" href="group__emaclite.html#ga444ab091bdc373bf2e1a266d5febecd0">XEmacLite_PhyRead()</a>.</p>

<p>Referenced by <a class="el" href="xemaclite__intr__example_8c.html#a96917622015e54b4adfc30cf3bc43b65">EmacLiteIntrExample()</a>, <a class="el" href="xemaclite__phy__loopback__example_8c.html#ab4299bd01a872463e209d193501a22d2">EmacLitePhyLoopbackExample()</a>, and <a class="el" href="xemaclite__polled__example_8c.html#a47117ea81b169056edf42281fab91cc2">EmacLitePolledExample()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
